﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AdminStyem.Repositories
{
    /// <summary>
    /// 接口
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRespository<T> where T : class 
    {
        /// <summary>
        ///查询
        /// </summary>
        /// <returns>返回任务</returns>
        Task<List<T>> GetAll();

        Task<List<T>> GetAll(Expression<Func<T, bool>> expression);
        /// <summary>
        ///查询一条
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> GetByid(int id);
        
        Task<int> add(T entity);

        Task<int> update(T entity);

        Task<int> delete(T entity);

        Task<int> AddRange(IEnumerable<T> entities);

        Task<int> UpdateRange(IEnumerable<T> Entities);

        Task<int> DeleteRange(IEnumerable<int> Ids);
        /// <summary>
        /// 查单条
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        Task<T> QueryFirstAsync(Expression<Func<T, bool>> predicate);

        IQueryable<T> Queryable();
    }
}
